using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;

namespace Xliff.Ui.Model
{
    public static class BindingExtensions
    {
        public static void BindWith(this TextBox textBox, object instance, string property)
        {
            textBox.SetBinding(TextBox.TextProperty,
                               new Binding
                               {
                                   Source = instance,
                                   UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                                   Path = new PropertyPath(property)
                               });
        }

        public static void BindWith(this CheckBox checkBox, object instance, string property)
        {
            checkBox.SetBinding(CheckBox.IsCheckedProperty, new Binding()
            {
                Source = instance,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Path = new PropertyPath(property)
            });
        }
    }
}